﻿using System.Data.Entity.ModelConfiguration;

using NeGroid.ChampionshipManager.Core;

namespace NeGroid.ChampionshipManager.Persistance.Mappings
{
	public class GoalMap : EntityTypeConfiguration<Goal>
	{
		public GoalMap()
		{
			HasKey(t => new { t.GameResultId, t.PlayerId, t.Date });

			HasRequired(t => t.Player)
				.WithMany(t => t.Goals)
				.HasForeignKey(t => t.PlayerId);
			HasOptional(t => t.PlayerAssisted)
				.WithMany(t => t.Assists)
				.HasForeignKey(t => t.PlayerAssistedId);

			ToTable("Goals");
		}
	}
}
